from bs4 import BeautifulSoup
import requests
import pandas
itemsary = []
for i in range(1, 26):
    res = requests.get('http://r.qidian.com/yuepiao?chn=-1&page='+str(i))
    soup = BeautifulSoup(res.text, 'html.parser')
    soup1 = soup.find(class_='rank-view-list')
    for items in soup1.find_all('li'):
        itemsary.append({'title': items.select('a')[1].text,
                         'name': items.select('a')[2].text,
                         'style': items.select('a')[3].text,
                         'describe': items.select('p')[2].text,
                         'url': items.select('a')[0]['href']})
itemsdf = pandas.DataFrame(itemsary)
print(itemsdf)
itemsdf.to_excel('小说.xlsx')
